import 'package:flutter/material.dart';
import 'package:flutter_time_manager/state/count_state.dart';
import 'package:provider/provider.dart';

class PageStateDemo01 extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    print("xxxx");
    return Scaffold(
        appBar: AppBar(
          leading: IconButton(icon: Icon(Icons.dehaze), onPressed: () => Navigator.of(context).pushNamed("/demo02")),
          title: Text("demo01"),
        ),
        body: Center(
          child: Consumer<Counter>(
            builder: (context, value, child) => Text("count: ${value.count}"),
          ),
        ),
        floatingActionButton: Consumer<Counter>(
          builder: (context, counter, child) => FloatingActionButton(
                onPressed: counter.increment,
                child: child,
              ),
          child: Icon(Icons.add),
        ));
  }
}

class PageStateDemo02 extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("demo02"),
      ),
      body: Center(
        child: Consumer<Counter>(
            builder: (context, counter, _) =>
                Text("demo02 count: ${counter.count}")),
      ),
    );
  }
}
